/**
 * Copyright © 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
 */
package com.jeeplus.modules.xs_book.entity;

import com.jeeplus.common.utils.SpringContextHolder;
import com.jeeplus.modules.xs_book.mapper.XsBookMapper;
import com.jeeplus.modules.xs_book_classify.entity.XsBookClassify;
import com.jeeplus.modules.xs_writer.entity.XsWriter;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.util.List;
import com.google.common.collect.Lists;

import com.jeeplus.core.persistence.DataEntity;
import com.jeeplus.common.utils.excel.annotation.ExcelField;
import com.jeeplus.modules.xs_writer.mapper.XsWriterMapper;
import lombok.Data;

/**
 * 书籍信息Entity
 * @author 天竹子
 * @version 2021-07-24
 */
@Data
public class XsBook extends DataEntity<XsBook> {
	
	private static final long serialVersionUID = 1L;
	@ExcelField(title="书籍名称", align=2, sort=1)
	private String name;		// 书籍名称
	@ExcelField(title="首字母", align=2, sort=2)
	private String letter;		// 首字母
	@ExcelField(title="书籍封面", align=2, sort=3)
	private String cover;		// 书籍封面
	@ExcelField(title="类型(1.看书2.听书)", dictType="type",align=2, sort=4)
	private String type;		// 类型(1.看书2.听书)
	@ExcelField(title="字数", align=2, sort=5)
	private Integer wordNumber;		// 字数
	@ExcelField(title="分类", fieldType=XsBookClassify.class, value="classify.classify", align=2, sort=6)
	private XsBookClassify classify;		// 分类
	@ExcelField(title="简介", align=2, sort=7)
	private String introduction;		// 简介
	@ExcelField(title="授权级别(1.授权作品2.驻站作品3.专属作品)",dictType="authori", align=2, sort=8)
	private String authorization;		// 授权级别(1.授权作品2.驻站作品3.专属作品)
	@ExcelField(title="是否原创(1.是2.否)",dictType="is_no", align=2, sort=9)
	private String isOriginal;		// 是否原创(1.是2.否)
	@ExcelField(title="状态(1.连载小说2.完本小说3.vip小说4.免费小说)", dictType="state_book",align=2, sort=10)
	private String state;		// 状态(1.连载小说2.完本小说3.vip小说4.免费小说)
	@ExcelField(title="作家名称", fieldType=XsWriter.class, value="writer.name", align=2, sort=11)
	private XsWriter writer;		// 作家名称
	@ExcelField(title="是否上架(1.是2.否)",dictType="is_no", align=2, sort=12)
	private String isShelves;		// 是否上架(1.是2.否)
	@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
	@ExcelField(title="上架时间", align=2, sort=13)
	private Date shelvesDate;		// 上架时间
	@ExcelField(title="推荐票数量", align=2, sort=14)
	private Integer recommendNumber;		// 推荐票数量
	@ExcelField(title="月票数量", align=2, sort=15)
	private Integer monthlyTicketNumber;		// 月票数量
	@ExcelField(title="章节价格", align=2, sort=16)
	private String chapterPrice;		// 章节价格
	@ExcelField(title="广告链接", align=2, sort=17)
	private String advertisingUrl;		// 广告链接

	public XsBook() {
		super();
		this.setIdType(IDTYPE_AUTO);
	}

	public XsBook(String id){
		super(id);
	}

	public static XsBook getValue(String name){
		XsBook xsBook = new XsBook();
		xsBook.setName(name);
		List<XsBook> list = SpringContextHolder.getBean(XsBookMapper.class).findList(xsBook);
		if(list.size()>0){
			return list.get(0);
		}else{
			return new XsBook ();
		}
	}
}